package com.session04;

import java.util.*;

public class TestCollections {
    public static void main(String[] args) {
        Set<Integer> mySet = new HashSet<>();
        mySet.add(5);
        mySet.add(4);
        mySet.add(9);

        Integer max = Collections.max(mySet);
        System.out.println(max);

        Integer min = Collections.min(mySet);
        System.out.println(min);

        System.out.println("------------------");

        List<Integer> lst = new ArrayList<>();
        lst.addAll(mySet);
        Collections.sort(lst);//是按照从小到大的自然顺序进行排序
        for (Integer i : lst) {
            System.out.print(i + " ");
        }
        System.out.println();
        System.out.println("------------------");

        Collections.reverse(lst);//反转
        for (Integer i : lst) {
            System.out.print(i + " ");
        }

        System.out.println();
        System.out.println("------------------");

        Collections.shuffle(lst);//混排
        for (Integer i : lst) {
            System.out.print(i + " ");
        }

        System.out.println();


    }
}
